home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 1
/
CU Amiga Magazine CD-ROM Special Edition (1995)(EMAP Images)(GB)[Issue 1995-11].iso
/
Aminet
/
comm
/
tcp
/
AmiTCPsdk_40.lha
/
AmiTCP-4.0
/
src
/
netlib
/
_fstat.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-09-29
|
1KB
|
64 lines
RCS_ID_C="$Id: _fstat.c,v 4.1 1994/09/29 23:09:02 jraja Exp $";
/*
* _fstat.c - fstat() for Network Support Library (SAS/C)
*
* Copyright © 1994 AmiTCP/IP Group,
* Network Solutions Development Inc.
* All rights reserved.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
/* DOS 3.0 and MuFS extensions to file info block */
#include "fibex.h"
#include <proto/dos.h>
#include <proto/utility.h>
#include <ios1.h>
int fstat(int fd, struct stat *st)
{
struct UFB *ufb = chkufb(fd);
if (st == NULL || ((1 & (long)st) == 1)) {
errno = EFAULT;
return -1;
}
if (ufb == NULL || ufb->ufbflg == 0) {
errno = EBADF;
return -1;
}
if (ufb->ufbflg & UFB_SOCK) { /* a socket */
long value;
long size = sizeof(value);
bzero(st, sizeof(*st));
/* st->st_dev = ??? */
st->st_mode = S_IFSOCK | S_IRUSR | S_IWUSR;
st->st_uid = geteuid();
st->st_gid = getegid();
if (getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &value, &size) == 0)
st->st_blksize = value;
return 0;
} else { /* ordinal file */
if (ExamineFH(ufb->ufbfh, __dostat_fib)) {
__dostat(__dostat_fib, st);
st->st_dev = (dev_t)((struct FileHandle *)BADDR(ufb->ufbfh))->fh_Type;
return 0;
} else {
errno = EIO;
return -1;
}
}
}